package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"group-card/model/entity"
	"group-card/rpc/card/cardclient"
	"group-card/rpc/card/internal/svc"
)

type PublishDeleteLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPublishDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PublishDeleteLogic {
	return &PublishDeleteLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PublishDeleteLogic) PublishDelete(in *cardclient.PublishDeleteRequest) (*cardclient.PublishDeleteResponse, error) {
	var ctx context.Context
	err := l.svcCtx.PublishModel.Delete(ctx, &entity.CardPublishReq{
		Id: in.Id,
	})

	if err != nil {
		return nil, err
	}

	return &cardclient.PublishDeleteResponse{}, nil
}
